
import AbsWindow from "../../framework/AbsWindow";
import {WindowName} from "../../framework/reflect/WindowName";
import MenuWindow from "./MenuWindow";
import Context from "../../framework/Context";
import WeaponItem from "../comp/WeaponItem";
import LocalStorage from "../../framework/utils/LocalStorage";
import LoadResData from "../../framework/LoadResData";
import ListView from "../../framework/component/ListView";
import ListAdapter from "../comp/ListAdapter";
const {ccclass, property} = cc._decorator;
@ccclass
@WindowName("WeaponWindow")
export default class WeaponWindow extends AbsWindow {

    @property(cc.Node)
    private returnBtn:cc.Node=null;
    @property(ListView)
    private dataScrollView:ListView = null;

    public onShow() {
        this.setClickListener(this.returnBtn,this.onReturnBtn);
        const adapter = new WeaponListAdapter();
        var weaponData = LoadResData.weaponsData;
        cc.log("ddd",weaponData)
        adapter.setDataSet(weaponData)
        this.dataScrollView.setAdapter(adapter)
    }
    public listen(): string[] {
        return []
    }
    public handleMessage(message: string, args: any[]): boolean {
        switch (message) {
        }
        return false
    }
    private onReturnBtn(){
        this.context.closeWindow(WeaponWindow);
    }
}

export class WeaponListAdapter extends ListAdapter{

    public updateView(item: cc.Node, posIndex: number) {
        const comp = item.getComponent(WeaponItem)
        comp.setInfo(this.getItem(posIndex))
        
        
    }

}